package com.pactera.jep.service.sys.service;

import java.util.List;

import org.springframework.web.multipart.MultipartFile;

import com.pactera.jep.core.exception.ServiceException;
import com.pactera.jep.orm.service.CRUDService;
import com.pactera.jep.sys.model.Attachment;

/**
 * Ftp附件Service
 * @author ghost
 *
 */
public interface FtpAttachmentService extends CRUDService<Attachment, String>{
	
	/**
	 * 删除指定的附件
	 * @param id
	 * @throws ServiceException
	 */
	int deleteById(String id) throws ServiceException;
	
	
	/**
	 * 删除指定对象的附件
	 * @param entityId
	 * @return
	 * @throws ServiceException
	 */
	int deleteByEntityId(String entityId) throws ServiceException;
	
	
	/**
	 * 删除指定会话的附件
	 * @param uploadSession
	 * @return
	 * @throws ServiceException
	 */
	int deleteByUploadSession(String uploadSession) throws ServiceException;
	
	
	/**
	 * 上传文件，一次上传多个
	 * @param entityId			关联对象ID
	 * @param attachTypeCode	附件类型
	 * @param uploadSession		上传会话
	 * @param fileMap			文件列表
	 * @throws ServiceException
	 */
	List<Attachment> upload(String staffCode, String entityId, String attachTypeCode, String uploadSession, MultipartFile file) throws ServiceException;
	
	
	/**
	 * 查询与 entityId 或 uploadSession 相匹配的附件
	 * @param entityId
	 * @param uploadSession
	 * @param entityType
	 * @return
	 * @throws ServiceException
	 */
	List<Attachment> select(String entityId, String uploadSession, String entityType) throws ServiceException;
	
	
	/**
	 * 将某次会话上传的文件与指定的 entityId 相关联
	 * @param entityId
	 * @param uploadSession
	 * @return
	 * @throws ServiceException
	 */
	int associate(String entityId, String uploadSession) throws ServiceException;
	
	/**
	 * 复制附件
	 * @param entityId
	 * @param entityType
	 * @return
	 * @throws ServiceException
	 */
	List<Attachment> copy(String entityId, String entityType) throws ServiceException;

}
